package com.be.beadmin.service.controller;

import com.be.beadmin.common.entity.PageEntity;
import com.be.beadmin.common.utils.ResultModel;
import com.be.beadmin.service.dto.input.SerialNumberDto;
import com.be.beadmin.service.service.SerialNumberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
* @author chenwei
* @date 2023-01-16
**/
@Api(tags = {"系统服务模块"})
@RestController
public class SerialNumberController {

    @Autowired
    private  SerialNumberService serialNumberService;

    @ApiOperation("获取流水码分页信息")
    @PostMapping(value = "/system/getSerialNumberByPage")
    public ResultModel getSerialNumberByPage(@RequestBody PageEntity pageEntity)  {
        return ResultModel.success(serialNumberService.getSerialNumberByPage(pageEntity)) ;
    }

    @ApiOperation("增加流水码主键信息")
    @PostMapping("/system/addSerialNumber")
    public ResultModel addSerialNumber(@RequestBody SerialNumberDto serialNumberDto){
        serialNumberService.addSerialNumber(serialNumberDto);
        return ResultModel.success(ResultModel.ADD);
    }

    @ApiOperation("删除流水码信息")
    @PostMapping("/system/delSerialNumber")
    public ResultModel delSerialNumber(@RequestBody SerialNumberDto serialNumberDto){
        serialNumberService.delSerialNumber(serialNumberDto.getId());
        return ResultModel.success(ResultModel.DELETE);
    }

    @ApiOperation("更新流水码信息")
    @PostMapping("/system/updateSerialNumber")
    public ResultModel updateSerialNumber(@RequestBody SerialNumberDto serialNumberDto){
        serialNumberService.updateSerialNumber(serialNumberDto);
        return ResultModel.success(ResultModel.UPDATE);
    }
}